class CreateTags < ActiveRecord::Migration
    def self.up
        create_table :tags do |t|
            t.string :name, null: false
            t.string :synonyms
            t.integer :referenced_count, default: 0
            t.string :created_by, null: false
            t.string :updated_by
            
            t.timestamps
        end
		
		add_index :tags, :name, unique: true
		add_index :tags, :synonyms
        
        create_table :documents_tags do |t|
            t.integer :document_id
            t.integer :tag_id
        end
        
        #create_table :related_tags do |t|
        #    t.integer :tag_id
        #    t.integer :related_tag_id
        #end
        
    end

    def self.down
        drop_table :tags
        drop_table :documents_tags
        #drop_table :related_tags
    end
end
